package com.sky.aspect;

import com.sky.annotation.DeleteRedisCache;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class DeleteRedisCacheAspect {
    @Pointcut("execution(* com.sky.controller.admin.*.*(..)) && @annotation(com.sky.annotation.DeleteRedisCache)")
    public void deleteRedisCache() {

    }

    @After("deleteRedisCache()")
    public void deleteRedisCache(JoinPoint joinPoint) {
        log.info("清理redis缓存数据");
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        signature.getMethod().getAnnotation(DeleteRedisCache.class);
        Object[] args = joinPoint.getArgs();
    }
}
